<template>
    <div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>单位名称</label>
            </div>
            <div>
                <p>{{detailData.ProjectName}}</p>
            </div>
        </div>
        <div class="form-item form-item-style2">
            <div class="label-title">
                <label>演练题目</label>
            </div>
            <div>
                <p class="textarea">{{detailData.DrillName}}</p>
            </div>
        </div>
        <div class="form-item form-item-style2">
            <div class="label-title">
                <label>主要情景</label>
            </div>
            <div>
                <p class="textarea">{{detailData.DrillCase}}</p>
            </div>
        </div>
        <div class="form-item form-item-style2">
            <div class="label-title">
                <label>演练方式</label>
            </div>
            <div>
                <p class="textarea">{{detailData.DrillType}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>演练时间</label>
            </div>
            <div>
                <p>{{detailData.DrillTime?detailData.DrillTime.split(' ')[0]:''}}</p>
            </div>
        </div>
        <div class="form-item form-item-style2">
            <div class="label-title">
                <label>参加人数</label>
            </div>
            <div>
                <p class="textarea">{{detailData.DrillNum}}</p>
            </div>
        </div>
        <div class="form-item form-item-style2">
            <div class="label-title">
                <label>演练地点</label>
            </div>
            <div>
                <p class="textarea">{{detailData.DrillPlace}}</p>
            </div>
        </div>
        <div class="form-item form-item-style2">
            <div class="label-title">
                <label>动用设备(台次)</label>
            </div>
            <div>
                <p class="textarea">{{detailData.DrillEquipment}}</p>
            </div>
        </div>
        <div class="form-item form-item-style2">
            <div class="label-title">
                <label>动用车辆(台次)</label>
            </div>
            <div>
                <p class="textarea">{{detailData.DrillCost}}</p>
            </div>
        </div>
        <div class="form-item form-item-style2">
            <div class="label-title">
                <label>投入经费(万元)</label>
            </div>
            <div>
                <p class="textarea">{{detailData.DrillCar}}</p>
            </div>
        </div>
        <div class="form-item form-item-style2">
            <div class="label-title">
                <label>备注</label>
            </div>
            <div>
                <p class="textarea">{{detailData.DrillAssess}}</p>
            </div>
        </div>
        <div class="cut-off-rule"></div>
        <div class="form-section">
            <h3>
                演练脚本
            </h3>
            <div class="form-item form-item-style2"
                 v-for="(item,index) in detailData.RecordScripts"
                 :key="index">
                <div class="label-title">
                    <label>{{item.SteepName}}（{{item.LiableUserName}}）</label>
                </div>
                <div>
                    <p class="textarea">{{item.Duty}}</p>
                </div>
            </div>
        </div>
        <div class="cut-off-rule"></div>
        <div class="form-section">
            <h3>
                演练方案
            </h3>
            <div class="form-item form-item-style1"
                 v-for="(item,index) in detailData.DrillFile1"
                 :key="index"
                 @click="preview(item.FilePath)">
                <div class="label-title label-title1">
                    <label class="file-name">{{item.FileName}}</label>
                </div>
                <div class="right-section">
                    <span>预览</span>
                    <x-icon type="ios-arrow-right"
                            size="20"
                            class="icon-right"></x-icon>
                </div>
            </div>
        </div>
        <div class="cut-off-rule"></div>
        <div class="form-section">
            <h3>
                演练总结
            </h3>
            <div class="form-item form-item-style1"
                 v-for="(item,index) in detailData.DrillFile2"
                 :key="index"
                 @click="preview(item.FilePath)">
                <div class="label-title label-title1">
                    <label class="file-name">{{item.FileName}}</label>
                </div>
                <div class="right-section">
                    <span>预览</span>
                    <x-icon type="ios-arrow-right"
                            size="20"
                            class="icon-right"></x-icon>
                </div>
            </div>
        </div>
        <div class="cut-off-rule"></div>
        <div class="form-section">
            <h3>
                演练照片
            </h3>
            <div class="form-item form-item-style2">
                <div class="label-title space-between">
                    <div class="space-between">
                        <label>照片</label>
                    </div>
                    <span>当前共{{detailData.DrillFile3?detailData.DrillFile3.length:0}}张</span>
                </div>
                <div class="upload-wrap"
                     v-if="detailData.DrillFile3">
                    <!-- <upload v-if="imgList.length"
                            :imgList="imgList"></upload> -->
                    <div class="upload-item"
                         v-for="(item,index) in detailData.DrillFile3"
                         :key="index">
                        <img :src="item.FilePath"
                             :preview="1"
                             :large="item.FilePath"
                             alt="">
                    </div>
                </div>
            </div>
        </div>
        <myMenu></myMenu>
    </div>
</template>
<script>
import upload from '@/commonComponents/upload/index'
import myMenu from '@/commonComponents/menu'
export default {
    name: 'rescueRecordDetail',
    components: {
        upload,
        myMenu
    },
    data () {
        return {
            regImg: /\.(png|jpg|PNG|JPG|jpeg|JPEG|gif|GIF)$/,
            userInfo: {},
            detailData: {}
        }
    },
    created () {
        this.userInfo = JSON.parse(localStorage.getItem('userInfo')) || {}
        this.id = this.$route.query.id
        this.getDetail()
    },
    methods: {
        preview (filePath) {
            if (this.regImg.test(filePath)) {
                this.$router.push({
                    path: '/previewImg',
                    query: {
                        previewImg: filePath
                    }
                })
            } else {
                wx.miniProgram.navigateTo({
                    url: `/pages/openDocument/index?filePath=${filePath}`
                })
            }
        },
        getDetail () {
            var params = {
                'allowPaging': true,
                'business': 'GetRecordInfo',
                'data': {
                    'RecordId': this.id
                },
                'pageIndex': 0,
                'pageSize': 0,
                'tokenId': '',
                'userId': this.userInfo.userid
            }
            this.$axiosAjax.getConfigJson(params)
                .then((res) => {
                    if (res.data.code === 0) {
                        this.detailData = res.data.data
                    }
                }).catch((response) => {
                })
        }
    }
}
</script>
<style scoped>
.file-name {
    width: 250px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}
</style>
